package cn.gok.client.controller;

import cn.gok.client.service.GoodsService;
import cn.gok.common.resp.Result;
import cn.gok.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author shikundai
 * @date 2020/12/9
 * @time 17:37
 * @description 商品控制器
 */
@Controller
@RequestMapping("/client/goods")
public class ClientGoodsController {
    @Autowired
    private GoodsService goodsServise;
    /**
     * 描述：获得商品列表
     * @author shikundai
     * @date 2020/12/9
     * @time 17:40
     * @return
     */
    @GetMapping("/getGoodsCategoryList")
    @ResponseBody
    public Result getGoosCategoryList(){
        Result result= ResultUtil.success(goodsServise.getGoodsBrandList());
        return result;
    }

    /**
     * @author shikundai
     * @date 2020/11/1
     * @time 17:11
     * @description  处理运行时异常
     */
    @ExceptionHandler(RuntimeException.class)
    public Result Exception(Exception e){
        Result result=ResultUtil.error("");
        result.setMsg(e.getMessage());
        return result;
    }

    /**
     * 描述：获取广告轮播图
     * @author shikundai
     * @date 2020/12/13
     * @time 10:20
     */
    @GetMapping("/getAdverse")
    @ResponseBody
    public Result getAdverseList(){
        return ResultUtil.success(goodsServise.getGoodsAdvers());
    }

}
